;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (wigust packages wine)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix utils)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (gnu packages wine)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages cups)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages image)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages ghostscript)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gstreamer)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages openldap)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pulseaudio)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages mp3)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages photo)
  #:use-module (gnu packages samba)
  #:use-module (gnu packages scanner)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages video)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages xorg)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1))

(define-public winetricks
  (package
    (name "winetricks")
    (version "20171222")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://github.com/Winetricks/winetricks/archive/"
                           version ".tar.gz"))
       (file-name (string-append name "-" version ".tar.gz"))
       (sha256
        (base32
         "0kfhkfs8i1fbar4zqbwkahjdz4w9bcrs6b2dxyf9fxbkr1wij7lp"))))
    (build-system gnu-build-system)
    (arguments
     `(#:make-flags
       (list (string-append "PREFIX=" %output))
       #:tests?
       #f
       #:phases
       (modify-phases %standard-phases
         ;; Only Makefile.
         (delete 'configure)
         ;; (delete 'build)
         ;; (replace 'install
         ;;   (lambda* (#:key outputs #:allow-other-keys)
         ;;     (copy-recursively "src" (string-append
         ;;                              (assoc-ref outputs "out")
         ;;                              "/share/themes/Raleigh-Reloaded"))))
         )))
    (native-inputs
     `(("xmessage" ,xmessage)
       ("unzip" ,unzip)
       ("cabextract" ,cabextract)))
    (home-page "https://github.com/Winetricks/winetricks/")
    (synopsis "Winetricks is an easy way to work around problems in Wine ")
    (description "Winetricks is an easy way to work around problems in Wine.

It has a menu of supported games/apps for which it can do all the workarounds
automatically. It also lets you install missing DLLs or tweak various Wine
settings individually.")
    (license license:lgpl2.1)))

(define-public wine-no-gstreamer
  (package
    (inherit wine)
    (name "wine-no-gstreamer")
    (arguments
     (substitute-keyword-arguments (package-arguments wine)
       ((#:configure-flags flags)
        `(cons "--without-gstreamer" ,flags))))
    (inputs
     `(,@(alist-delete "gst-plugins-base" (package-inputs wine))))))

(define-public wine-1.9.6
  (package
    (inherit wine-no-gstreamer)
    (version "1.9.6")
    (source (origin
              (inherit (package-source wine))
              (uri (string-append "https://dl.winehq.org/wine/source/"
                                  (version-major+minor version)
                                  "/wine-" version ".tar.bz2"))
              (patches (search-patches "wine-1.9.6-gnutls.patch"
                                       "wine-1.9.6-cups.patch"))
              (sha256
               (base32
                "0mqm5jmrmz1ghk0mnmd1xqd8bkp051mc3jy1ajlyr2gxxqpqcarx"))))))
